// This example is part of Diogo's code snippet database.
// http://code.google.com/p/diogo-snippets
//
// The file presents a singleton example based on a Logger class.
// The Singleton design pattern ensures only one instance of the class in
// the application.

#ifndef SNIPPETS_PATTERNS_SINGLETON
#define SNIPPETS_PATTERNS_SINGLETON

class Logger
{
public:
	// Method to get the single instance of the Logger class in the application;
	// Method could also return a pointer, but reference is always better for compilers
	// and people;
	static Logger& getInstance();

private:
	// We have to be sure users can't create another instance of our singleton.
	// So we disable the use of constructors for others;
	Logger(); // empty constructor (always created by compiler as public if not defined);
	Logger (const Printer& rhs); // copy constructor (always created by compiler as public if not defined);
};

#endif // SNIPPETS_PATTERNS_SINGLETON